import unittest
import requests


class Testlogin(unittest.TestCase):
    def setUp(self) -> None:
        print("开始")


    def login_user_password(self):
        print("用户名密码是否合法")
        res = requests.get("http://127.0.0.1:8081/api/mall/v1/user/login?mobile=13007961112")
        # 解析返回参数
        res = res.json()
        # 对比
        recode = 1001
        self.assertEquals(recode,res['code'],res['message'])



    def username_valid(self):
        print("手机号是否正则")
        res = requests.get("http://127.0.0.1:8081/api/mall/v1/user/login?mobile=13007961112&code =12")
        res = res.json()
        recode = 1002
        self.assertEquals(recode, res['code'],res['message'])



    def tearDown(self) -> None:
        print("结束")


class HTMLTestRunner(object):
    pass


if __name__== "__main__":

    # 创建测试集
    suit = unittest.TestSuite()
    suit.addTest([Testlogin('login_user_password'),Testlogin('username_valid')])

    # 运行
    # runner = unittest.TextTestResult()
    # runner.run(suit)
    runner = HTMLTestRunner.HTMLTestRunner()
    runner.run()































